Show:

Q filter Class

Implements an input that filters an associated list (like an autocomplete)

Constructor

Q filter

(
  • [options]
)
Q.Tool

Parameters:

  • [options] Object optional

    Override various options for this tool

    • [name='filter'] String optional

      The name of the text input

    • [value=''] String optional

      The initial value of the text input

    • [placeholder] String optional

      Any placeholder text

    • [placeholders={}] Object optional

      Options for Q/placeholders, or null to omit it

    • [results=''] String optional

      HTML to display in the results initially. If setting them later, remember to call stateChanged('results')

    • [onFilter] Q.Event optional

      You are meant to attach an event handler to fetch and update results by editing the contents of the element pointed to by the second argument. The first argument is the content of the text input.

    • [onChoose] Q.Event optional

      This event occurs when one of the elements with class "Q_filter_result" is chosen. It is passed (element, details) where you can modify details.text to set the text which will be displayed in the text input to represent the chosen item.

    • [onClear] Q.Event optional

      This event occurs when the filter input is cleared

    • [onFocus] Q.Event optional

      This event occurs when input element focused

Returns:

Item Index

Methods

begin

() Boolean

Show the filtered results

Returns:

Boolean:

May return false if the tool is suspended, etc.

choose

(
  • [element]
)

Choose an item in the results.

Parameters:

end

(
  • [chosenText]
)

Hide the filtered results

Parameters:

  • [chosenText] Object optional

    the text of the chosen option, if any, to display in the input

setText

(
  • [chosenText]
  • [dontRefresh]
)

Set text in the input

Parameters:

  • [chosenText] String optional

    the text of the chosen option, if any, to display in the input Pass the empty string here to clear the filter and trigger the onClear method

  • [dontRefresh] Boolean optional

    pass true here to not refresh the filter